<?php
# User session management
require_once('includes/user_manage.php');
?>
<div class="alert">
   Se han actualizado las provincias.
</div>
<script type="text/javascript">
var mySelect=document.getElementById('zone_id');
while (mySelect.options.length) mySelect.remove(0); 
var myOption;
<?php
$country=new country();
$country->id=htmlentities($_GET["country"]);
$country->db_load_zones();

for($i = 0; $i < count($country->zones); $i++)
{
?>
	myOption=document.createElement('option');
	myOption.text="<?php echo $country->zones[$i]->name; ?>";
	myOption.value="<?php echo $country->zones[$i]->id; ?>";
<?php
	if ($user->id && $user->address->zone_id==$country->zones[$i]->id) {
?>
		myOption.selected=true;
<?php
	}
?>
	mySelect.add(myOption);
<?php
}
?>
// 'changeZones' is the value of the myFor attribute of the launcher element and for that the id name of this block/window
window.setTimeout(removeAlert,1000,document.getElementById('changeZones'));
function removeAlert(alert) {
	alert.parentNode.removeChild(alert);
}
</script>
